#include "imagetab.h"

ImageTab::ImageTab()
{
	_dib = NULL;
	_hasUnsavedChanges = false;
	_fileName = NULL;
}

ImageTab::~ImageTab()
{
	if( _fileName )
	{
		delete _fileName;
	}
}

bool ImageTab::hasUnsavedChanges() const
{
	return _hasUnsavedChanges;
}

void ImageTab::setHasUnsavedChanges( bool value )
{
	_hasUnsavedChanges = value;
}

wchar_t* ImageTab::fileName()
{
	return _fileName;
}

void ImageTab::setFileName( wchar_t *fileName )
{
	//We make a deep copy of the file name.
	size_t length = wcslen( fileName );
	wchar_t *newStr = new wchar_t[ length + 1 ];
	memcpy( newStr, fileName, length * sizeof( wchar_t ) );
	newStr[ length ] = L'\0';
	if( _fileName )
	{
		delete _fileName;
	}
	_fileName = newStr;
}

DIB* ImageTab::dib()
{
	return _dib;
}

void ImageTab::setDib( DIB *dib )
{
	_dib = dib;
}
